/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package view;

import interfaces.VareInterface;
import java.rmi.RemoteException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JLabel;
import javax.swing.JTextField;

/**
 *
 * @author Dorthe
 */
public class VareLinje_OpretOrdre extends javax.swing.JPanel {


    private VareInterface vare;
    private int tal;
    private double pris;
    /**
     * Creates new form VareLinje_OpretOrdre
     */
    public VareLinje_OpretOrdre(VareInterface vif, int tal) throws RemoteException {
        initComponents();
        vare = vif;
        this.tal = tal;
        jTextField_antalBestilles.setText(Integer.toString(tal));
        this.pris = vif.getVarePris();
        jLabel_varenavn.setText("Vare: " + vare.getVareNavn());
        jLabel_pris.setText("Pris: " + Double.toString(vare.getVarePris() * 1));
        jLabel_antalLager.setText("Lager: " + Integer.toString(vare.getAntal()));
    }
    
    public JTextField getAntal(){
        return jTextField_antalBestilles;
    }
    
    public VareInterface getVif(){
        return vare;
    }
    
    public void setAntal(int tal){
        this.tal = tal;
    }
    
    public JLabel getPrisLabel(){
        return jLabel_pris;
    }
    
    public void setPris(){
        try {
            jLabel_pris.setText("Samlet pris: " + Double.toString(vare.getVarePris() * tal));
        } catch (RemoteException ex) {
            Logger.getLogger(VareLinje_OpretOrdre.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    
    public double getSum(){
        double sum = 0;
        try {
            sum = vare.getVarePris() * tal;
        } catch (RemoteException ex) {
            Logger.getLogger(VareLinje_OpretOrdre.class.getName()).log(Level.SEVERE, null, ex);
        }
        return sum;
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel_varenavn = new javax.swing.JLabel();
        jLabel_antalLager = new javax.swing.JLabel();
        jLabel_pris = new javax.swing.JLabel();
        jTextField_antalBestilles = new javax.swing.JTextField();

        setOpaque(false);
        setPreferredSize(new java.awt.Dimension(380, 36));
        setLayout(null);

        jLabel_varenavn.setText("Varenavn");
        add(jLabel_varenavn);
        jLabel_varenavn.setBounds(0, 11, 110, 16);

        jLabel_antalLager.setText("Antal på lager");
        add(jLabel_antalLager);
        jLabel_antalLager.setBounds(130, 10, 60, 16);

        jLabel_pris.setText("Pris");
        add(jLabel_pris);
        jLabel_pris.setBounds(200, 10, 140, 16);
        add(jTextField_antalBestilles);
        jTextField_antalBestilles.setBounds(340, 0, 59, 30);
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel_antalLager;
    private javax.swing.JLabel jLabel_pris;
    private javax.swing.JLabel jLabel_varenavn;
    private javax.swing.JTextField jTextField_antalBestilles;
    // End of variables declaration//GEN-END:variables
}
